<?php

namespace app\payment\validate;

use think\Validate;

/**
 * 提现验证器
 */
class Withdrawal extends Validate
{

    //定义验证规则
    protected $rule = [
        'merchant_id|商户号' => 'require|number',
        'bank_type|银行卡类型' => 'require',
        'bank_name|收款银行名称' => 'require|chs',
        'name|收款人姓名' => 'require',
        'bank_card|收款银行卡' => 'require|number',
        'id_card|收款人身份证' => 'require',
        'account_type|账户类型' => 'require',
        'account_opening_branch|开户支行' => 'require',
        'couplet_number|联行号' => 'requireIf:account_type,公户|length:1,50',
        'province|省份名称' => 'require|chs',
        'city|城市名称' => 'require|chs',
        'manual_select|选择已经设置过的银行卡' => 'length:1,50',
        'cash|提现金额' => 'require|float|egt:0.01',
        'now_cash|到账金额' => 'float',
        'remark|本地备注' => '',
        'status|提现状态' => '',
        'order_id|本地提现订单号' => '',
        'other_order_id|第三方订单号' => 'length:1,50',
        'programmer_remark|程序员备注' => '',
    ];
    //定义验证提示
    protected $message = [
        'manual_select.require' => '选择已经设置过的银行卡不能为空',
        'other_order_id' => '第三方订单号不能为空',
    ];

    // 验证场景定义
    public function sceneClose()
    {
        return $this->only(['manual_select', 'cash'])
            ->append('manual_select', 'require')
            ->append('cash', 'require|number|egt:0.01');
    }

    // 验证场景定义
    public function sceneEdit()
    {
        return $this->only(['other_order_id'])
            ->append('other_order_id', 'requireIf:status,1|length:1,50');
    }
}
